package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lxmes.business.domain.CcCaigouDetail;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.CcChukuDetail;
import com.lxmes.business.service.ICcChukuDetailService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 出库详情Controller
 * 
 * @author 张志煜
 * @date 2022-06-29
 */
@Api(tags="出库详情主表")
@RestController
@RequestMapping("/business/chukudetail")
public class CcChukuDetailController extends BaseController
{
    @Autowired
    private ICcChukuDetailService ccChukuDetailService;

    /**
     * 查询出库详情列表
     */
    @ApiOperation("出库详情列表")
   // @PreAuthorize("@ss.hasPermi('business:chukudetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcChukuDetail ccChukuDetail)
    {
        startPage();
        List<CcChukuDetail> list = ccChukuDetailService.selectCcChukuDetailList(ccChukuDetail);
        return getDataTable(list);
    }

    /**
     * 导出出库详情列表
     */
    @PreAuthorize("@ss.hasPermi('business:chukudetail:export')")
    @Log(title = "出库详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcChukuDetail ccChukuDetail)
    {
        List<CcChukuDetail> list = ccChukuDetailService.selectCcChukuDetailList(ccChukuDetail);
        ExcelUtil<CcChukuDetail> util = new ExcelUtil<CcChukuDetail>(CcChukuDetail.class);
        util.exportExcel(response, list, "出库详情数据");
    }

    /**
     * 获取出库详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:chukudetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ccChukuDetailService.selectCcChukuDetailById(id));
    }

    /**
     * 添加出库库存物料
     */
    @GetMapping("/addChuKuStockinfo/{ids}")
    public AjaxResult addChuKuStockinfo(@PathVariable Long[] ids)
    {
        List<CcChukuDetail> list = ccChukuDetailService.addChuKuStockinfo(ids);
        return AjaxResult.success(list);
    }
    /**
     * 新增出库详情
     */
    @PreAuthorize("@ss.hasPermi('business:chukudetail:add')")
    @Log(title = "出库详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcChukuDetail ccChukuDetail)
    {
        return toAjax(ccChukuDetailService.insertCcChukuDetail(ccChukuDetail));
    }

    /**
     * 修改出库详情
     */
    @PreAuthorize("@ss.hasPermi('business:chukudetail:edit')")
    @Log(title = "出库详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcChukuDetail ccChukuDetail)
    {
        return toAjax(ccChukuDetailService.updateCcChukuDetail(ccChukuDetail));
    }

    /**
     * 删除出库详情
     */
    @PreAuthorize("@ss.hasPermi('business:chukudetail:remove')")
    @Log(title = "出库详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccChukuDetailService.deleteCcChukuDetailByIds(ids));
    }
}
